package com.bzkj.web.controller.basicInfo;

import com.bzkj.basicinfo.service.SelectService;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @projectName: bzkj-wms
 * @package: com.bzkj.web.controller.basicInfo
 * @className: SelectController
 * @description: 前端下拉框数据
 * @author: C1309
 * @createDate: 2024年11月20日
 * @version: v1.0
 */
@RestController
@RequestMapping("/select")
public class SelectController extends BaseController {
    @Resource
    private SelectService selectService;

    /**
     * 查询仓库信息
     *
     * @return 查询结果
     */
    @GetMapping("/sto_stock")
    public AjaxResult selectStock() {
        ArrayList<HashMap<String, Object>> stoStockList = selectService.selectStoStock();
        return AjaxResult.success(stoStockList);
    }

    /**
     * 查询单据状态
     */
    @GetMapping("/bill_status")
    public AjaxResult selectBillStatus() {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectStoStatus();
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC用户信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccUser")
    public AjaxResult selectNccUser(@RequestParam(name = "username", required = false) String username) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccUser(username);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC物料信息
     *
     * @param materialName 查询条件
     * @param modeType     模式类型（0：按名称查，1：按编码查）
     * @return 查询结果
     */
    @GetMapping("/nccMaterial")
    public AjaxResult selectNccMaterial(@RequestParam(name = "materialName", defaultValue = "") String materialName,
                                        @RequestParam(name = "modeCode", defaultValue = "1") int modeType) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccMaterial(materialName, modeType);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC生产厂商信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccManufacturer")
    public AjaxResult selectNccManufacturer(@RequestParam(name = "manufacturerName", defaultValue = "") String manufacturerName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccManufacturer(manufacturerName);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC生产厂商信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccManufacturer-pk")
    public AjaxResult selectNccManufacturerPk(@RequestParam(name = "manufacturerName", defaultValue = "") String manufacturerName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccManufacturerPk(manufacturerName);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC部门信息(pk值)
     *
     * @return 查询结果
     */
    @GetMapping("/nccDept")
    public AjaxResult selectNccDept(@RequestParam(name = "deptName", defaultValue = "") String deptName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccDept(deptName);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC物料信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccMaterial-code")
    public AjaxResult selectNccMaterialCode(@RequestParam(name = "materialName", defaultValue = "") String materialName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccMaterialCode(materialName);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 根据NCC物料主键信息查询NCC物料信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccMaterial-code/{code}")
    public AjaxResult selectNccMaterialByCode(@PathVariable String code) {
        HashMap<String, Object> stoStatusList = selectService.selectNccMaterialByCode(code);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 根据NCC物料主键、模式类型、批次号查询NCC库存信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccMaterialInfo")
    public AjaxResult selectNccMaterialByPrimaryKey(@RequestParam(name = "primaryKey", required = false, defaultValue = "") String primaryKey,
                                                    @RequestParam(name = "modeType", required = false, defaultValue = "") String modeType,
                                                    @RequestParam(name = "batchNo", required = false, defaultValue = "") String batchNo) {
        List<HashMap<String, Object>> stoStatusList = selectService.selectSkuInfoByPrimaryKey(primaryKey, modeType, batchNo);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 根据NCC物料主键信息查询NCC物料信息
     *
     * @return 查询结果
     */
    @GetMapping("/nccMaterial/{primaryKey}")
    public AjaxResult selectNccMaterialByPrimaryKey(@PathVariable String primaryKey) {
        HashMap<String, Object> stoStatusList = selectService.selectNccMaterialByPrimaryKey(primaryKey);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询NCC供应商信息
     *
     * @param supplierName 供应商名称
     * @return 查询结果
     */
    @GetMapping("/nccSupplier")
    public AjaxResult selectNccSupplier(@RequestParam(name = "supplierName", defaultValue = "") String supplierName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccSupplier(supplierName);
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 查询TMS物流企业信息
     *
     * @param logistics 物流企业名称
     * @return 查询结果
     */
    @GetMapping("/tms-logistics")
    public AjaxResult tmsLogistics(@RequestParam(name = "logistics", required = false) String logistics) {
        ArrayList<HashMap<String, Object>> qmsLogisticsList = selectService.selectTmsLogistics(logistics);
        return AjaxResult.success(qmsLogisticsList);
    }

    /**
     * 查询供应商主键信息
     *
     * @param supplierName 供应商名称
     * @return 查询结果
     */
    @GetMapping("/supplierPk")
    public AjaxResult selectSupplierPk(@RequestParam(name = "supplierName", required = false) String supplierName) {
        ArrayList<HashMap<String, Object>> supplierPkList = selectService.selectSupplierPk(supplierName);
        return AjaxResult.success(supplierPkList);
    }

    /**
     * 查询NCC用户主键信息
     *
     * @param username 用户名
     * @return 查询结果
     */
    @GetMapping("/nccUserCode")
    public AjaxResult selectNccUserPk(@RequestParam(name = "username", required = false) String username) {
        ArrayList<HashMap<String, Object>> nccUserCodeList = selectService.selectNccUserCode(username);
        return AjaxResult.success(nccUserCodeList);
    }

    @GetMapping("/stockAll")
    public AjaxResult stockAll() {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectstockAll();
        return AjaxResult.success(stoStatusList);
    }

    @GetMapping("/selectParentClassId")
    public AjaxResult selectParentClassId() {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectParentClassId();
        return AjaxResult.success(stoStatusList);
    }

    @GetMapping("/areaAll")
    public AjaxResult selectAreaAll() {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectAreaAll();
        return AjaxResult.success(stoStatusList);
    }

    /**
     * 获取所有的图片信息
     *
     * @Author wangzhichao
     * @Date 2024/12/17 09:26:40
     */
    @GetMapping("findAllBasicPicInfo")
    public R findAllBasicPicInfo(String type) {
        return selectService.findAllBasicPicInfo(type);
    }

    /**
     * 查询NCC部门信息(code值)
     *
     * @return 查询结果
     */
    @GetMapping("/nccDeptCode")
    public AjaxResult selectNccDeptCode(@RequestParam(name = "deptName", defaultValue = "") String deptName) {
        ArrayList<HashMap<String, Object>> stoStatusList = selectService.selectNccDeptCode(deptName);
        return AjaxResult.success(stoStatusList);
    }

}
